/* eslint-disable react/prop-types */
import { hasToken } from '@/utils/storage'
import { Redirect, Route } from 'react-router'

export default function AuthRoute (props) {
  console.log(props)
  const Com = props.component
  return (
    <Route
      path={props.path}
      render={() => {
        if (hasToken()) {
          return <Com />
        } else {
          console.log('没有token...')
          return <Redirect to="/login" />
        }
      }}
    />
  )
}
